/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package qviewer;

import gui.form.MainForm;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.ini4j.Ini;
import util.OShandler;

/**
 *
 * @author Quân
 */
public class QViewer {

    public static MainForm mainForm;
    public static final String myName = "qViewer";
    public static final String cacheFolderName = "cache";
    public static final String xmlFile = "qViewer.xml";
    public static final String configFolder = "folder.ini";
    public static final String configAlbum = "album.ini";
    public static Ini iniFolder = null;
    public static Ini iniAlbum = null;

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        setupEnvironment();
        mainForm = new MainForm();
        mainForm.setVisible(true);
        ServiceManager.getInstance().setMainForm(mainForm);
    }

    public static void setupEnvironment() {
        OShandler oShandler = OShandler.getInstance();
        File app = oShandler.getAppDataFolder();
        File root = new File(app, qviewer.QViewer.myName);
        if (!root.isDirectory()) {
            root.mkdirs();
        }
        File album = new File(root, qviewer.QViewer.configAlbum);
        File folders = new File(root, qviewer.QViewer.configFolder);
        try {
            if (!album.exists()) {
                album.createNewFile();
            }
            iniAlbum = new Ini(album);

            if (!folders.exists()) {
                folders.createNewFile();
            }
            iniFolder = new Ini(folders);
        } catch (IOException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
